interface Waiter {
  anjiao: boolean
  say(): void
}

interface Teacher {
  anjiao: boolean
  skill(): void
}

// function judgeWho(person: Waiter | Teacher) {
//   if (person.anjiao) {
//     ;(person as Teacher).skill()
//   } else {
//     ;(person as Waiter).say()
//   }
// }

// function judgeWhoTow(person: Waiter | Teacher) {
//   if ('skill' in person) {
//     person.skill()
//   } else {
//     person.say()
//   }
// }

// function add(x: number | string, y: number | string) {
//   if (typeof x === 'string' || typeof y === 'string') {
//     return `${x}${y}`
//   }
// }

class NumberObj {
  constructor(public count: number) {}
}

function addObj(x: object | NumberObj, y: object | NumberObj) {
  if (x instanceof NumberObj && y instanceof NumberObj) {
    return x.count + y.count
  }
  return 0
}
